#
#  Copyright 2022 The Open Islands Authors. All Rights Reserved.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#


import abc
import typing
from abc import ABCMeta

from pyoi.context.types import FederatedPacketRouting, FederatedPacketHeaders


class MQChannelABC(metaclass=ABCMeta):
    @abc.abstractmethod
    def __init__(
            self, routing_info: FederatedPacketRouting, host: str = None, port: int = None, **kwargs
    ):
        ...

    @property
    @abc.abstractmethod
    def role(self) -> str:
        ...

    @property
    @abc.abstractmethod
    def node_id(self) -> str:
        ...

    @property
    @abc.abstractmethod
    def routing_info(self) -> FederatedPacketRouting:
        ...

    @property
    @abc.abstractmethod
    def group(self) -> str:
        ...

    @group.setter
    @abc.abstractmethod
    def group(self, group: str):
        ...

    @property
    @abc.abstractmethod
    def send_topic(self) -> str:
        ...

    @property
    @abc.abstractmethod
    def receive_topic(self) -> str:
        ...

    @abc.abstractmethod
    def publish(self, headers: FederatedPacketHeaders, data: bytes):
        ...

    @abc.abstractmethod
    def publish_to(self, topic: str, headers: FederatedPacketHeaders, data: bytes):
        ...

    @abc.abstractmethod
    def consume(self) -> typing.Tuple[object, FederatedPacketHeaders, bytes]:
        ...

    @abc.abstractmethod
    def consume_on(self, topic) -> typing.Generator[object, FederatedPacketHeaders, bytes]:
        ...

    @abc.abstractmethod
    def ack(self, deliver: typing.Any, **kwargs):
        ...

    @abc.abstractmethod
    def cancel(self):
        ...

    @abc.abstractmethod
    def close(self):
        ...
